<!--# include virtual="/admin/common/html/header.html"-->
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 信息价管理 <span class="c-gray en">&gt;</span> 信息价审核 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		状态：<span class="select-box inline">
			<select name="state"  id="state" class="select" >
				<option value="" selected="selected">全部分类</option>
				<option value="0" >待审核</option>
				<option value="1">已审核</option>
				<option value="2">未通过</option>
			</select>
		</span>
		工程分类：<span class="select-box inline">
			<select name=""  id="catalogId" class="select">
				<option value="" selected="selected">全部分类</option>
			</select>
		</span> 
		工程名称：<input  id="costName" name="costName"  class="input-text" style="width:200px;"> 
		<button name="searchButton" id="searchButton" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>搜索</button>
	</div>
	<!--<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">

		<a class="btn btn-primary radius" onclick="batchCheck()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>批量审核</a>
		</span> 
		<span class="r"></span> 
	</div>-->
	<div class="mt-20">
		<table id="firm-post-list" class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="13"><input type="checkbox" name="" value=""></th>
					<th width="50">工程名字</th>
					<th width="50">工程分类</th>
					<th width="50">工程地点</th>
					<th width="150">总建筑面积</th>
					<th width="50">建筑总高度</th>
					<th width="50">建筑总层数</th>
					<th width="50">提交人</th>
					<th width="100">提交时间</th>
					<th width="50">审核人</th>
					<th width="100">审核时间</th>
					<th width="25" >状态</th>
					<th width="50">操作</th>
				</tr>
			</thead>
			<tbody>				
			</tbody>
		</table>
	</div>
</div>
<!--# include virtual="/admin/common/html/_footer.html"-->
<!--# include virtual="/admin/modules/datashare/base/_list_curd.html"-->
<script type="text/javascript">
	var catalogObj={};
	$(function() {
		$.ajax({
			type:"post",
			url:"/guidance_service/front/data/catalog/searchByCache.do",
			async:false,
			success:function(result){
				var catalog=result.data;
				$.each(catalog,function(i,item){
					if(item.parentId=='1'){
						$("#catalogId").append("<option value='"+item.catalogId+"'>"+item.catalogName+"</option>");
					}
					catalogObj[item.catalogId]=item;
				});
			}
		});
		
		var user = {
			getQueryCondition: function(data) {
				var param = {};
				param.costName = $.trim($("#costName").val());
				param.catalogId = $.trim($("#catalogId").val());
				param.pageNumber = Number(data.start/data.length)+1  || 1;
				param.pageSize = data.length   || 15;
				param.state=$("#state").val();
				return param;
			}
		};
	    var dataTable = $("#firm-post-list").zosoftDataTable({
	    	searchButton:"#searchButton",
	    	"aaSorting":[[ 5, "asc" ]] ,
	    	"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,1,2,3,4,6,7 ] }]  ,
			ajax: function(data, callback) { //ajax配置为function,手动调用异步查询
				$.post("/guidance_service/front/data/dataList.do", user.getQueryCondition(data),function(result) {
						//封装返回数据，这里仅演示了修改属性名
						var returnData = {};
						returnData.recordsTotal = result.data.totalRow;
						returnData.recordsFiltered = result.data.totalRow; //后台不实现过滤功能，每次查询均视作全部结果
						returnData.data = result.data.list;
						callback(returnData);
				});
			},
			//使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
			//data 这里是固定不变的，id，name，age，sex等为你数据里对应的属性
			columns: [
				{
					data: "costId",
					render: function(data) {
						return '<input type="checkbox" name="costId" value="' + data + '" class="costId">';
					}
				},
				{
					data: "costName",
					render: function(data, type, row) {
						return '<a style="text-decoration:none" class="ml-5" onClick="data_open(\''+data+'\',\'/admin/modules/datashare/info/infoList.html?costId=' 
						+ row.costId + '\')" href="javascript:;" title="查看详情">'+data+'</a>';
					}
				},
				{
					data: "catalogId", //
					render: function(data,type, row) {
						return data || "";
					}
				},
				{
					data: "address",
					render: function(data) {
						return data || "";
					}
				},
				{
					data: "totalArea",
					render: function(data, type, row) {
						return data || "";
					}
				},
				{
					data: "projectHeight", //
					render: function(data) {
						return data || "";
					}
				},
				{
					data: "totalFloor", //
					render: function(data, type, row) {
						return data || "";
					}
				},
				{
					data: "createUserId",
					render: function(data) {
						//sessionStorage.setItem("fieldId",data)
						//return sessionStorage.getItem(data);
						return data || "";
					}
				},
				{
					data: "createTime",
					render: function(data) {
						//sessionStorage.setItem("fieldId",data)
						//return sessionStorage.getItem(data);
						return data || "";
					}
				},
				{
					data: "updateUserId",
					render: function(data) {
						//sessionStorage.setItem("fieldId",data)
						//return sessionStorage.getItem(data);
						return data || "";
					}
				},
				{
					data: "updateTime",
					render: function(data) {
						//sessionStorage.setItem("fieldId",data)
						//return sessionStorage.getItem(data);
						return data || "";
					}
				},
				{
					data: "state",
					render: function(data) {
						if ('0'==data) {
	                    	return '<span class="label label-primary  radius">待审核</span>';
	                    }else if('1'==data){
	                    	return '<span class="label label-success  radius">已审核</span>';
	                    }else if('2'==data){
	                    	return '<span class="label label-warning  radius">未通过</span>';
	                    }
					}
				},
				{
					data: "costId",
					render: function(data, type, row) {
						return '<a style="text-decoration:none" class="ml-5" onClick="data_open(\'审核\',\'/admin/modules/datashare/base/_form.html?costId=' 
						+ row.costId + '&manage=1\')" href="javascript:;" title="完善详细信息">完善详细信息</a>'
//						return '<a style="text-decoration:none" onClick="policies_shenhe(this,' + data + ')" href="javascript:;" title="审核">审核</a>' +
//						return	'<a style="text-decoration:none" class="ml-5" onClick="guidance_edit(this,\'add.html?guidanceId=' + data + '\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>' +
//							'<a style="text-decoration:none" class="ml-5" onClick="guidance_del(this,' + data + ')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>';
					}
				}
			]
		});
	});
	
/*审核*/
function guidances_shenhe(obj,guidanceId){
	layer.confirm('审核申请？', {
		btn: ['通过','不通过','取消'], 
		shade: false,
		closeBtn: 0
	},function(index){
		$.post("/guidance_service/front/guidance/batchUpdate.do",{ guidanceId:guidanceId,state:1 },function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					//$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" data-id="'+$(obj).attr("data-id")+'"  onClick="article_start(this,10001)" href="javascript:;" title="开放"><i class="Hui-iconfont" style="font-size: 18px;">&#xe603;</i></a>');
					for(var i=0;i<obj.length;i++){
						
						$(obj[i]).parents("tr").find("span").removeClass().addClass("label label-success radius").text("已审核"); 
					}
					//$(obj).remove();
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	},function(index){
		$.post("/guidance_service/front/guidance/batchUpdate.do",{ guidanceId:guidanceId,state:2 },function(result){
			if(result.resultCode == 200){
				layer.msg("请求成功", {icon:6,time:1000},function(){
					for(var i=0;i<obj.length;i++){
						
						$(obj[i]).parents("tr").find("span").removeClass().addClass("label label-warning  radius").text("未通过"); 
					}
					layer.close(index);
				});
			}else{
				layer.msg('操作失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	});
}

//批量审核
function batchCheck(){
	var Ids ="";  
	var objs=[];
	$('input[name="guidanceId"]:checked').each(function(){    
		Ids+=$(this).val()+",";    
		objs.push($(this));
	});
	guidances_shenhe(objs,Ids);
}

</script>
</body>
</html>